const Destructuring=document.getElementById("demo") const object={ firstName:"subash", lastName:"panneerselvam", } let { firstName,lastName,age=24 }=object; Destructuring.innerHTML=firstName+" "+lastName +" "+age;
const array= [firstName="john", lastName="doe"] const array1=document.getElementById("demo1") let[array2,array3]=array array1.innerHTML=array2+" "+array3;
const map=document.getElementById("hello") const fruits=new Map([ ["apple",100], ["banana",100], ["orange",100] ]); let text=""; for(const [key,value]of fruits){ text+="
"+key+"is"+value; } map.innerHTML=textconst num1=[1,2,3] const num2=[4,5,6] const oprator=[...num1,...num2] const result=document.getElementById("hello1"); result.innerHTML=oprator;
let myfunction=(a,b)=>{ return a+b; } const res=(4,5) const tot=document.getElementById("hello2"); tot.innerHTML=res;
const state={ user:{id:1,name:"asha"}, todos:['buy milk','pay bills'] }; const newState = { ...state, user: { ...state.user, name: 'Asha Rao' }, todos: [...state.todos, 'walk dog'] }; document.getElementById("hello3").innerHTML=state.user.name document.getElementById("hello4").innerHTML= newState.user.name
const num=[1,2,3,4,5.6] const double=num.map(n=>n*2) const filter=num.filter(n=>n%2==0) const reduce=num.reduce((acc,n)=>acc+n,0) document.getElementById("hello5").innerHTML= double; document.getElementById("hello6").innerHTML= filter; document.getElementById("hello7").innerHTML= reduce;
const data= new Promise((res,rej)=>{ const name="ashok"; if(name){ res(name); } else{ rej("not Found") } }) data.then((name) => { console.log( "success ok") alert("success ok") }).catch((err) => { console.error("not found") }) .finally(()=>{ console.log( " PROGRESS COMPLETED"); })
export const PI = 3.14159; export function area(radius) { return PI * radius * radius; } export default function greet(name) { return `Hello, ${name}!`; }
import greet, { PI, area } from './moduleA.js'; console.log(greet('Ravi')); console.log('PI:', PI); console.log('area(2):', area(2));
Hello, Ravi! PI: 3.14159 area(2): 12.56636